window.config = {
	url: 'http://125.124.203.168:3306', //服务的请求地址
	// url:'http://125.124.203.168',//服务的请求地址

	//分页
	pageSize: 10,
	pageStart: 0,

	//
	appid: 'wxa76b772e31f113da',
	redirect_uri: 'http://baidu.com'
}

function BeeResponse(pageTotal, data, code, msg) {
	this.pageTotal = pageTotal;
	this.data = data;
	this.code = code;
	this.msg = msg;
}
/**
 * 非分页请求
 * @param {Object} url
 * @param {Object} data
 * @param {Object} callback
 */
function ajax(url, data, callback) {
	$.ajax({
		url: url,
		data: data,
		success: function(json) {
			var result = JSON.parse(json);
			if (result.code == 1) {
				let list = JSON.parse(result.data);
				callback(new BeeResponse(0, list, result.code, result.msg));
			} else {
				callback(new BeeResponse(0, [], result.code, result.msg));
			}
		}
	});
}
/**
 * 分页请求
 * @param {Object} url
 * @param {Object} data
 * @param {Object} callback
 */
function pageAjax(url, data, callback) {
	$.ajax({
		url: url,
		data: data,
		success: function(json) {
			var result = JSON.parse(json);
			if (result.code == 1) {
				let list = JSON.parse(result.data);
				callback(new BeeResponse(list.pageTotal, list.list, result.code, result.msg));
			} else {
				callback(new BeeResponse(0, [], result.code, result.msg));
			}
		}
	});
}

function uploadAjax(url, data, callback) {
	$.ajax({
		url: url,
		data: data,
		method: 'post',
		processData: false,
		// 告诉jQuery不要去设置Content-Type请求头						
		contentType: false, //必须
		success: function(json) {
			var result = JSON.parse(json);
			if (result.code == 1) {
				let list = JSON.parse(result.data);
				callback(new BeeResponse(0, [], result.code, result.msg));
			} else {
				callback(new BeeResponse(0, [], result.code, result.msg));
			}
		}
	});
}
/**
 * 获取浏览器信息
 */
function myBrowser() {
	var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
	var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
	var isIE = userAgent.indexOf("compatible") > -1 &&
		userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
	var isEdge = userAgent.indexOf("Edge") > -1; //判断是否IE的Edge浏览器
	var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
	var isSafari = userAgent.indexOf("Safari") > -1 &&
		userAgent.indexOf("Chrome") == -1; //判断是否Safari浏览器
	var isChrome = userAgent.indexOf("Chrome") > -1 &&
		userAgent.indexOf("Safari") > -1; //判断Chrome浏览器
	if (isIE) {
		var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
		reIE.test(userAgent);
		var fIEVersion = parseFloat(RegExp["$1"]);
		if (fIEVersion == 7) {
			return "IE7";
		} else if (fIEVersion == 8) {
			return "IE8";
		} else if (fIEVersion == 9) {
			return "IE9";
		} else if (fIEVersion == 10) {
			return "IE10";
		} else if (fIEVersion == 11) {
			return "IE11";
		} else {
			return "0";
		} //IE版本过低
		return "IE";
	}
	if (isOpera) {
		return "Opera";
	}
	if (isEdge) {
		return "Edge";
	}
	if (isFF) {
		return "FF";
	}
	if (isSafari) {
		return "Safari";
	}
	if (isChrome) {
		return "Chrome";
	}
}
function getAge(strBirthday){
	
	var _self = this;
	var returnAge;
	var strBirthdayArr = strBirthday.split("-");
	var birthYear = strBirthdayArr[0];
	var birthMonth = strBirthdayArr[1];
	var birthDay = strBirthdayArr[2];
	
	var d = new Date();
	_self.nowYear = d.getFullYear();
	_self.nowMonth = d.getMonth() + 1;
	_self.nowDay = d.getDate();

	if (_self.nowYear == birthYear) {
		var monthDiff = _self.nowMonth - birthMonth; //月之差
		if (monthDiff < 0) {
			returnAge ="0月";
		} else {
			returnAge = monthDiff+"个月";
		}		
	} else {
		var ageDiff = _self.nowYear - birthYear; //年之差
		if (ageDiff > 0) {
			if (_self.nowMonth == birthMonth) {
				var dayDiff = _self.nowDay - birthDay; //日之差
				if (dayDiff < 0) {
					returnAge = ageDiff - 1+"岁";
				} else {
					returnAge = ageDiff+"岁";
				}
			} else {
				var monthDiff = _self.nowMonth - birthMonth; //月之差
				if (monthDiff < 0) {
					returnAge = ageDiff - 1+"岁"+monthDiff+"月";
				} else {
					returnAge = ageDiff+"岁"+monthDiff+"月";
				}
			}
		} else {
			returnAge = -1; //返回-1 表示出生日期输入错误 晚于今天
		}
	}
	return returnAge; //返回周岁年龄
}
